package com.anycl.design.behavioral.interpreter;

/**
 * 非终结符（运算构造类）
 */
public class NonTerminalExpression extends AbstractExpression {
    // 代表运算符两侧的参数，即a、b
    private AbstractExpression left;
    private AbstractExpression right;

    public NonTerminalExpression(AbstractExpression left, AbstractExpression right) {
        this.left = left;
        this.right = right;
    }

    @Override
    int interpreter(Context context) {
        if (!context.getSymbol().equalsIgnoreCase("")) {
            return this.left.interpreter(context) + this.right.interpreter(context);
        }

        return 0;
    }
}
